package zunyi03;

/**
 * 形状类
 */
public class Shape {
    private double length;//长
    private double wide; //宽
    private double radius;//半径

    public double getLength() {
        return length;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public double getWide() {
        return wide;
    }

    public void setWide(double wide) {
        this.wide = wide;
    }

    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        this.radius = radius;
    }

    //图形是长方形，计算周长 d=2（长+宽）
    public void rectangleD(Shape shape){
    System.out.println("长方形的周长为："+(shape.getLength()+shape.getWide())*2);
    }
    //图形是长方形，计算长方形面积 s=长*宽
    public void rectangleS(Shape shape){
        System.out.println("长方形的面积为："+(shape.getLength()*shape.getWide()));
    }
    //图形是圆形，计算圆的周长d=2πR
    public void circularD(Shape shape){
        System.out.println("圆的周长为："+2*3.14*shape.getRadius());
    }
    //图形式圆形，计算半径s=πR^2
    public void circularS(Shape shape){
        System.out.println("圆的面积为："+3.14*(shape.getRadius()*shape.getRadius()));
    }
}
